import { getRole } from "../../utils/request"

const state = {
  // 角色列表初始值
  role:[],
}

const mutations = {
  changeRole(state,arr){
    state.role = arr
  }
}

const actions = {
  roleActions(context){
    // 发起角色列表的请求
    getRole().then(res=>{
      context.commit('changeRole',res.data.list)
    })
  }
}

const getters = {
  role(state){
    return state.role;
  }
}

export default {
  state,
  mutations,
  actions,
  getters,
  namespaced:true,//使用命名空间
}
